package com.jixiang.goods.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jixiang.goods.service.GsTypePicService;
import com.jixiang.model.common.dtos.ResponseResult;
import com.jixiang.model.goods.dtos.AddGoodsTypePicDtos;
import com.jixiang.model.goods.dtos.AddGoodsTypeWxPicDtos;
import com.jixiang.model.goods.dtos.GoodsBySecTypeDtos;
import com.jixiang.model.goods.entity.GsGoodsType;
import com.jixiang.goods.service.GsGoodsTypeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (GsGoodsType)表控制层
 *
 * @author makejava
 * @since 2023-10-14 21:13:16
 */
@RestController
@RequestMapping("goodsType")
public class GsGoodsTypeController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private GsGoodsTypeService gsGoodsTypeService;
    @Resource
    private GsTypePicService gsTypePicService;

    @ApiOperation("获取商品类型")
    @GetMapping("/getGoodsTypeList")
    public ResponseResult getGoodsTypeList(){
        return gsGoodsTypeService.getGoodsTypeList();
    }

    @ApiOperation("获取商品类型")
    @GetMapping("/getGoodsTypePage")
    public ResponseResult getGoodsTypePage(@RequestParam(value = "pageSize",required = false,defaultValue = "10")int pageSize,
                                           @RequestParam(value = "pageNum",required = false,defaultValue = "1")int pageNum){
        return gsGoodsTypeService.getGoodsTypePage(pageNum,pageSize);
    }

    @ApiOperation("获取父级商品类型")
    @GetMapping("/getParentGoodsTypeList")
    public ResponseResult getParentGoodsTypeList(){
        return gsGoodsTypeService.getParentGoodsTypeList();
    }

    @ApiOperation("添加商品类型")
    @PostMapping("/addGoodsType")
    public ResponseResult addGoodsType(@RequestBody(required = true)GsGoodsType gsGoodsType){
        return gsGoodsTypeService.addGoodsType(gsGoodsType);
    }

    @ApiOperation("获取商品类型ById")
    @GetMapping("/getGoodsTypeById")
    public ResponseResult getGoodsTypeById(@RequestParam(required = true)String id){
        return gsGoodsTypeService.getGoodsTypeById(id);
    }

    @ApiOperation("修改商品类型")
    @PostMapping("/updateGoodsType")
    public ResponseResult updateGoodsType(@RequestBody(required = true)GsGoodsType gsGoodsType){
        return gsGoodsTypeService.updateGoodsType(gsGoodsType);
    }

    @ApiOperation("删除商品类型")
    @DeleteMapping("/deleteGoodsTypeById")
    public ResponseResult deleteGoodsTypeById(@RequestParam(required = true)String id){
        return gsGoodsTypeService.deleteGoodsTypeById(id);
    }

    @ApiOperation("APP获取商品类型")
    @GetMapping("/appGetGoodsTypeList")
    public ResponseResult appGetGoodsTypeList(){
        return gsGoodsTypeService.appGetGoodsTypeList();
    }

    @ApiOperation("APP获取商品类型和数据")
    @GetMapping("/appGetGoodsTypeLayout")
    public ResponseResult appGetGoodsTypeLayout(){
        return gsGoodsTypeService.appGetGoodsTypeLayout();
    }

    @ApiOperation("删除商品类型缓存")
    @PostMapping("/clearGoodsTypeCache")
    public ResponseResult clearGoodsTypeCache(){
        return gsGoodsTypeService.clearGoodsTypeCache();
    }

    @ApiOperation("admin获取商品类型图片")
    @GetMapping("/getGoodsTypePic")
    public ResponseResult getGoodsTypePic(@RequestParam(required = true,value = "id")String id){
        return gsTypePicService.getGoodsTypePic(id);
    }
    @ApiOperation("添加商品类型图片")
    @PostMapping("/addPic")
    public ResponseResult addPic(@RequestBody(required = true) AddGoodsTypePicDtos addGoodsTypePicDtos){
        return gsGoodsTypeService.addPic(addGoodsTypePicDtos);
    }
    @ApiOperation("app获取商品类型数据通过id")
    @GetMapping("/appGetGoodsTypeDataById")
    public ResponseResult appGetGoodsTypeDataById(@RequestParam(required = true,value = "id")String id){
        return gsGoodsTypeService.appGetGoodsTypeDataById(id);
    }

    @ApiOperation("app获取商品类型图片数据通过id")
    @GetMapping("/appGetGoodsTypePicDataById")
    public ResponseResult appGetGoodsTypePicDataById(@RequestParam(required = true,value = "id")String id){
        return gsGoodsTypeService.appGetGoodsTypePicDataById(id);
    }

    @ApiOperation("app获取二级商品类型图片数据通过id")
    @GetMapping("/appGetSecondGoodsTypeDataById")
    public ResponseResult appGetSecondGoodsTypeDataById(@RequestParam(required = true,value = "id")String id){
        return gsGoodsTypeService.appGetSecondGoodsTypeDataById(id);
    }

    @ApiOperation("app获取二级商品类型商品数据通过二级分类id")
    @PostMapping("/appGetGoodsInfoBySecondGoodsTypeId")
    public ResponseResult appGetGoodsInfoBySecondGoodsTypeId(@RequestBody(required = true) GoodsBySecTypeDtos goodsBySecTypeDtos){
        return gsGoodsTypeService.appGetGoodsInfoBySecondGoodsTypeId(goodsBySecTypeDtos);
    }

    @ApiOperation("admin获取商品类型微信图片")
    @GetMapping("/adminGetGoodsTypeWxPic")
    public ResponseResult adminGetGoodsTypeWxPic(@RequestParam(required = true,value = "id")String id){
        return gsGoodsTypeService.getGoodsTypeWxPic(id);
    }

    @ApiOperation("admin添加商品类型微信图片")
    @PostMapping("/adminAddGoodsTypeWxPic")
    public ResponseResult adminAddGoodsTypeWxPic(@RequestBody(required = true) AddGoodsTypeWxPicDtos addGoodsTypeWxPicDtos){
        return gsGoodsTypeService.dddGoodsTypeWxPic(addGoodsTypeWxPicDtos);
    }

    @ApiOperation("wx获取商品推荐")
    @GetMapping("/WxGetGoodsListByRecommend")
    public ResponseResult WxGetGoodsListByRecommend(@RequestParam(required = false,value = "pageNum",defaultValue = "1")int pageNum,
                                                    @RequestParam(required = false,value = "pageSize",defaultValue = "10")int pageSize){
        return gsGoodsTypeService.WxGetGoodsListByRecommend(pageNum,pageSize);
    }
}

